#include <gtest/gtest.h>
#include <unordered_map>
#include <iostream>

/*
    全局事件
    在所有单元测试之前执行SetUp
    在所有单元测试之后执行TearDown
*/

std::unordered_map<std::string, std::string> dict;
class HashMapTest : public testing::Environment
{
public:
    virtual void SetUp() override
    {
        std::cout << "测试前:提前准备数据!!\n";
        dict.insert(std::make_pair("Hello", "你好"));
        dict.insert(std::make_pair("hello", "你好"));
        dict.insert(std::make_pair("雷吼", "你好"));
    }
    virtual void TearDown() override
    {
        std::cout << "测试结束后:清理数据!!\n";
        dict.clear();
    }
};

TEST(hash_case_test, find_test)
{
    auto it = dict.find("hello");
    ASSERT_NE(it, dict.end());
}
TEST(hash_case_test, size_test)
{
    ASSERT_GT(dict.size(), 0);
}

int main(int argc, char *argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new HashMapTest);

    RUN_ALL_TESTS();
    return 0;
}